﻿using AutoMapper;
using MediatR;
using S.Eartag.API.Application.Command.MarkedConditionCommand;
using S.Eartag.Domain.Model;
using S.Eartag.Infrastructure.Impl;
using S.Eartag.Infrastructure.Interface;

namespace S.Eartag.API.Application.CommandHandlers.MarkedConditionCommandHandler
{
    public class MarkedConditionUpdateCommandHandler : IRequestHandler<MarkedConditionUpdateCommand, int>
    {
        private readonly IMarkRepository markRepository;
        private readonly IMapper mapper;
        public MarkedConditionUpdateCommandHandler(IMarkRepository markRepository, IMapper mapper)
        {
            this.markRepository = markRepository;
            this.mapper = mapper;
        }

        public async Task<int> Handle(MarkedConditionUpdateCommand request, CancellationToken cancellationToken)
        {
            request.UpdateBy = "李四";
            request.UpdateDate = DateTime.Now;
            return await markRepository.Update(mapper.Map<Mark>(request));
        }
    }
}
